<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <p:growl id="messages"/>
    <div align="center">
        <div style="width: 60%">
            <p:fieldset legend ="#{i18n['project.tab.basic']}" id="fields">
            <table width="100%">
                <tr>
                    <td>
                        <label style="font-weight: bold;">#{i18n['project.common.name']}</label>
                    </td>
                    <td align="right">
                        <p:inputText value="#{projectBackingBean.project.name}" style="width: 100%"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label style="font-weight: bold;">#{i18n['project.common.description']}</label>
                    </td>
                    <td align="right" width="80%">
                        <p:inputText value="#{projectBackingBean.project.description}" style="width: 100%"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label style="font-weight: bold;">#{i18n['project.common.status']}</label>
                    </td>
                    <td>
                        <p:selectOneMenu style="width: 150px" value="#{projectBackingBean.selectedStatus}">
                            <f:selectItem itemLabel="#{i18n['common.select.defaultLabel']}" />
                            <c:forEach items="#{projectBackingBean.statuses}" var="status">
                                <f:selectItem itemValue="#{status.id}" itemLabel="#{status.name}"/>
                            </c:forEach>
                        </p:selectOneMenu>
                    </td>
                </tr>
            </table>
            <h:panelGrid columns="3">
                <h:panelGrid>
                    <label style="font-weight: bold;">#{i18n['project.common.database']}</label>
                    <p:selectOneMenu style="width: 200px" value="#{projectBackingBean.selectedDatabase}">
                        <f:selectItem itemLabel="#{i18n['common.select.defaultLabel']}" />
                        <c:forEach items="#{projectBackingBean.databases}" var="database">
                            <f:selectItem itemLabel="#{database.name}" itemValue="#{database.id}"/>
                        </c:forEach>
                    </p:selectOneMenu>
                </h:panelGrid>
                <h:panelGrid>
                    <label style="font-weight: bold;">#{i18n['project.common.language']}</label>
                    <p:selectOneMenu style="width: 200px" value="#{projectBackingBean.selectedLanguage}">
                        <f:selectItem itemLabel="#{i18n['common.select.defaultLabel']}" />
                        <c:forEach items="#{projectBackingBean.languages}" var="language">
                            <f:selectItem itemLabel="#{language.name}" itemValue="#{language.id}"/>
                        </c:forEach>
                    </p:selectOneMenu>
                </h:panelGrid>
                <h:panelGrid>
                    <label style="font-weight: bold;">#{i18n['project.common.package']}</label>
                    <p:selectOneMenu style="width: 200px" value="#{projectBackingBean.selectedTemplate}">
                        <f:selectItem itemLabel="#{i18n['common.select.defaultLabel']}" />
                        <c:forEach items="#{projectBackingBean.packageTemplates}" var="package">
                            <f:selectItem itemLabel="#{package.name}" itemValue="#{package.id}"/>
                        </c:forEach>
                    </p:selectOneMenu>
                </h:panelGrid>
            </h:panelGrid>
        </p:fieldset>
    </div>
    <br/>
    <div style="width: 60%" align="center">
        <p:fieldset legend="#{i18n['project.tab.properties']}" toggleable="true" id="advance">
            <ui:include src="/WEB-INF/facelets/project/datasource.xhtml"/>
        </p:fieldset>
    </div>
        <div style="width: 60%; text-align: right;">
            <p:commandButton 
                value="#{i18n['project.common.save']}" 
                rendered="#{isCreate}" 
                action="#{projectBackingBean.save}"
                update="fields, advance, messages, renderPanel, plugin">
            </p:commandButton>
            <p:commandButton 
                value="#{i18n['project.common.modify']}" 
                rendered="#{isModify}"
                action="#{projectBackingBean.modify}"
                update="fields, advance, messages, renderPanel, plugin">
            </p:commandButton>
            <p:commandButton 
                value="#{i18n['project.common.clear']}" 
                action="#{projectBackingBean.clear}"
                rendered="#{isCreate}" 
                update="fields, advance">
            </p:commandButton>
        </div>
    </div>
</ui:composition>